home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / uucp103d / part09 < prev    next >
Encoding:
Internet Message Format  |  1990-02-04  |  59.2 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i053: uucp 1.03D - unix compatible uucp/mail/news system, Part09/16
  5. Message-ID: <11292@xanth.cs.odu.edu>
  6. Date: 4 Feb 90 02:37:20 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: overload!dillon (Matt Dillon)
  9. Lines: 2307
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12.  
  13. Submitted-by: overload!dillon (Matt Dillon)
  14. Posting-number: Volume 90, Issue 053
  15. Archive-name: unix/uucp-1.03d/part09
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 9 (of 16)."
  24. # Contents:  man/MAPS src/News060/rnews.c src/getty/getty.c
  25. # Wrapped by tadguy@xanth on Sat Feb  3 20:51:15 1990
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'man/MAPS' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'man/MAPS'\"
  29. else
  30. echo shar: Extracting \"'man/MAPS'\" \(18172 characters\)
  31. sed "s/^X//" >'man/MAPS' <<'END_OF_FILE'
  32. X# The UUCP map is posted to newsgroup comp.mail.maps.
  33. X#
  34. X# From rn, the map can be easily unpacked with a command such as
  35. X#    43-46w | (cd ~uucp/uumap ; sh)
  36. X# or you can use John Quarterman's script to automatically unpack the files.
  37. X# All files intended as pathalias input being with "d." and "u.", thus
  38. X#    pathalias Path.* uumap/[du].*
  39. X# is a useful command to run.  (You supply Path.* with local additions.)
  40. X# 
  41. X# The map is also available on a demand basis at a number of hosts who
  42. X# have volunteered to make their copy available to the general public ;
  43. X# details of this access are posted separately in file "network".
  44. X# 
  45. X# The files are organized by country, using the ISO 3166 3 letter country
  46. X# code for each country.  Each file has a name like u.iso.r1.r2.s, where
  47. X# "iso" is the country code, r1, r2, etc are regions and subregions
  48. X# (e.g. states in the USA, provinces in Canada, etc.) and s is a sequence
  49. X# number (usually 1, but sometimes 2, 3, and up may be provided to keep
  50. X# individual files down to a reasonable size, thus, u.usa.ca is separated
  51. X# into two regions: [135] for southern, [246] for northern.)
  52. X#
  53. X# The map contains two types of files: u.* and d.* files.  The d.* files
  54. X# are for domains registered in the UUCP Zone.  The u.* files are for
  55. X# UUCP hosts that do not have officially registered domains, but rather
  56. X# belong to the unofficial ".UUCP domain".  Membership in the UUCP Zone
  57. X# allows organizations and individuals to register official, unique,
  58. X# domain names, recognized by all major academic computing networks
  59. X# worldwide.  For more information about joining the UUCP Zone, send
  60. X# electronic mail to the UUCP Project at one of the addresses
  61. X#    uucp-query@stargate.com
  62. X#    {uiucdcs,rutgers}!stargate!uucp-query
  63. X#    stargate!uucp-query@rutgers.edu
  64. X# or, if you cannot send electronic mail, telephone
  65. X#    +1 213 868 1134
  66. X# We strongly encourage you to send email if at all possible, since it
  67. X# cuts down on telephone tag and is much more efficient on our volunteer
  68. X# workforce.
  69. X# 
  70. X# This map can be used to generate mail routes with pathalias.  Pathalias
  71. X# was posted to Usenet in January 1986 and will be posted again as needed
  72. X# The map is also useful to determine the person to contact when a problem
  73. X# arises, and to find someone for a new site to connect to.
  74. X# 
  75. X# Please check the entry for your host (and any neighbors for whom you know
  76. X# the information and have the time) for correctness and completeness.
  77. X# Please send corrections and additional information to uucpmap@rutgers.UUCP
  78. X# or rutgers!uucpmap or uucpmap@rutgers.EDU.
  79. X# 
  80. X# This map is maintained by a group of volunteers, making up part of the UUCP
  81. X# Project.  These people devote many hours of their own time to helping out
  82. X# the UUCP community by keeping this map up to date.  The volunteers include:
  83. X#
  84. X#
  85. X# Jeff Janock - jeff@necntc.nec.com
  86. X#   USA: Conneticut, Maine, Massachusetts, New Hampshire, Rhode Island, Vermont
  87. X#
  88. X#
  89. X# Nicholas (Nike) Horton - horton@reed.uucp
  90. X#   USA: Delaware, Maryland, New Jersey, Virginia, Washington DC,
  91. X#   West Virginia
  92. X# 
  93. X#
  94. X# Rayan Zachariassen rayan@ai.toronto.edu
  95. X#   CANADA: All provinces
  96. X# 
  97. X#
  98. X# Bill Blue - bblue@crash.uucp
  99. X#   USA: Arizona, California (Southern half)
  100. X# 
  101. X#
  102. X# Erik Fair - nca-maps@ucbvax.berkeley.edu
  103. X#   USA: California (Northern half)
  104. X# 
  105. X# 
  106. X# David Schmidt - davids@iscuva.iscs.com
  107. X#   USA: Alaska, Idaho, Oregon, Montana, Washington, Wyoming
  108. X# 
  109. X# 
  110. X# Doug McCallum - dougm@ico.isc.com
  111. X#   USA: Arkansas, Colorado, Iowa, Kansas, Louisiana, Mississippi, Nebraska,
  112. X#        New Mexico, Oklahoma, Texas, Utah
  113. X# 
  114. X#
  115. X# Piet Beertema - Europe (piet@cwi.nl)
  116. X#   Europe: all countries (unless otherwise noted)
  117. X# 
  118. X# 
  119. X# Mikel Manitius - map-request@codas.att.com
  120. X#   USA: Florida
  121. X#
  122. X#
  123. X# Jeff Lee - jeff@ics.gatech.edu
  124. X#   USA: Georgia
  125. X# 
  126. X# 
  127. X# Tim Thompson - tgt@stargate.com
  128. X#   USA: Ohio
  129. X#
  130. X#
  131. X# Dave Zimmerman - dpz@rutgers.edu
  132. X#   USA: Alabama, Illinois, Indiana, North Carolina, North Dakota,
  133. X#        Pennsylvania, South Carolina, South Dakota, Tennessee, Wisconsin
  134. X#
  135. X#
  136. X# Bob Leffler - bob@rel.eds.com
  137. X#   USA: Michigan
  138. X#
  139. X#
  140. X# Rob Robertson - rob@philiabs.philips.com
  141. X#   USA: New York
  142. X#
  143. X#
  144. X# Hokey - hokey@plus5.com
  145. X#   USA: Missouri
  146. X# 
  147. X#
  148. X# David Herron - david@e.ms.uky.edu
  149. X#   USA: Kentucky
  150. X# 
  151. X#
  152. X# Brian Richter - brianr@rosevax.rosemount.com
  153. X#   USA: Minnesota
  154. X# 
  155. X#
  156. X# Torben Nielson, Bob Cunningham - torben@uhmanoa.UUCP, bob@uhmanoa.UUCP
  157. X#   USA: Hawaii
  158. X# 
  159. X#
  160. X# Haesoon Cho - nmc@sorak.kaist.ac.kr
  161. X#   Korea: all regions
  162. X# 
  163. X#
  164. X# Tohru Asami - asami@kddspeech.kddlabs.jp
  165. X#   Japan: all regions
  166. X# 
  167. X#
  168. X# Robert Elz, Dave Davey - map-coord@munnari.UUCP
  169. X#   Australia: all regions
  170. X# 
  171. X#
  172. X# Paul Graham - pjg@unrvax.unr.edu
  173. X#   USA: Nevada
  174. X#
  175. X#
  176. X# Susana Lilik - susana@indovax.uucp
  177. X#   Indonesia: all regions
  178. X#
  179. X#
  180. X# Mel Pleasant - pleasant@rutgers.edu
  181. X#   Singapore: all regions
  182. X#   New Zealand: all regions
  183. X# 
  184. X# 
  185. X
  186. X# Please note that the purpose of this map is to make routers within
  187. X# UUCP work.  The eventual direction is to make the map smaller (through
  188. X# the use of domains), not larger.  As such, sites with lots of local
  189. X# machines connected together are encouraged to create a few gateway
  190. X# machines and to make arrangements that these gateways can forward mail
  191. X# to your local users.  We would prefer not to have information listing
  192. X# the machines on your local area networks, and certainly not your
  193. X# personal computers and workstations.  If you need such information for
  194. X# local mail delivery, create a supplement in pathalias form which you
  195. X# do not publish, but which you combine with the published data when you
  196. X# run pathalias.  We also do not want information about machines which
  197. X# are not on UUCP, that is, which are not reachable with the ! notation
  198. X# from the main UUCP cluster.
  199. X#
  200. X# If you don't have pathalias, it has been posted to mod.sources most
  201. X# recently in October 1987.  If you don't have access to a mod.sources
  202. X# archive, contact the mod.sources moderator (currently Rich Salz,
  203. X# sources@uunet.uu.net.)
  204. X# 
  205. X# The remainder of this file describes the format of the UUCP map data.
  206. X# It was written July 9, 1985 by Erik E. Fair <ucbvax!fair>, and last
  207. X# updated July 12, 1985 by Mark Horton <stargate!mark>.
  208. X# 
  209. X# The entire map is intended to be processed by pathalias, a program
  210. X# that generates UUCP routes from this data.  All lines beginning in `#'
  211. X# are comment lines to pathalias, however the UUCP Project has defined a
  212. X# set of these comment lines to have specific format so that a complete
  213. X# database could be built.
  214. X# 
  215. X# The generic form of these lines is
  216. X# 
  217. X# #<field id letter><tab><field data>
  218. X# 
  219. X# Each host has an entry in the following format.  The entry should
  220. X# begin with the #N line, end with a blank line after the pathalias
  221. X# data, and not contain any other blank lines, since there are ed, sed,
  222. X# and awk scripts that use expressions like /^#N $1/,/^$/ for the
  223. X# purpose of separating the map out into files, each containing one site
  224. X# entry.
  225. X# 
  226. X# #N    UUCP name of site
  227. X# #S    manufacturer machine model; operating system & version
  228. X# #O    organization name
  229. X# #C    contact person's name
  230. X# #E    contact person's electronic mail address
  231. X# #T    contact person's telephone number
  232. X# #P    organization's address
  233. X# #L    latitude / longitude
  234. X# #R    remarks
  235. X# #U    netnews neighbors
  236. X# #W    who last edited the entry ; date edited
  237. X# #
  238. X# sitename    .domain
  239. X# sitename    remote1(FREQUENCY), remote2(FREQUENCY),
  240. X#     remote3(FREQUENCY)
  241. X# 
  242. X# Example of a completed entry:
  243. X# 
  244. X# #N    ucbvax
  245. X# #S    DEC VAX-11/750; 4.3 BSD UNIX
  246. X# #O    University of California at Berkeley
  247. X# #C    Robert W. Henry
  248. X# #E    ucbvax!postmaster
  249. X# #T    +1 415 642 1024
  250. X# #P    573 Evans Hall, Berkeley, CA 94720
  251. X# #L    37 52 29 N / 122 13 44 W
  252. X# #R    This is also UCB-VAX.BERKELEY.EDU [10.2.0.78] on the internet
  253. X# #U    decvax ibmpa ucsfcgl ucbtopaz ucbcad
  254. X# #W    ucbvax!fair (Erik E. Fair); Sat Jun 22 03:35:16 PDT 1985
  255. X# #
  256. X# ucbvax    .ucbvax.Berkeley.EDU
  257. X# ucbvax    decvax(DAILY/4), ihnp4(DAILY/2),
  258. X#     sun(POLLED)
  259. X# 
  260. X# Specific Field Descriptions
  261. X# 
  262. X# #N    system name
  263. X# 
  264. X# Your system's UUCP name should go here. Either the uname(1) command
  265. X# from System III or System V UNIX; or the uuname(1) command from
  266. X# Version 7 UNIX will tell you what UUCP is using for the local UUCP
  267. X# name.
  268. X# 
  269. X# One of the goals of the UUCP Project is to keep duplicate UUCP host
  270. X# names from appearing because there exist mailers in the world which
  271. X# assume that the UUCP name space contains no duplicates (and attempts
  272. X# UUCP path optimization on that basis), and it's just plain confusing
  273. X# to have two different sites with the same name.
  274. X# 
  275. X# At present, the most severe restriction on UUCP names is that the name
  276. X# must be unique somewhere in the first six characters, because of a
  277. X# poor software design decision made by AT&T for the System V release of
  278. X# UNIX.
  279. X# 
  280. X# This does not mean that your site name has to be six characters or
  281. X# less in length. Just unique within that length.
  282. X# 
  283. X# With regard to choosing system names, HARRIS'S LAMENT:
  284. X# 
  285. X#     ``All the good ones are taken.''
  286. X# 
  287. X# #S    machine type; operating system
  288. X# 
  289. X# This is a quick description of your equipment. Machine type should be
  290. X# manufacturer and model, and after a semi-colon(;), the operating
  291. X# system name and version number (if you have it). Some examples:
  292. X# 
  293. X#     DEC PDP-11/70; 2.9 BSD UNIX
  294. X#     DEC PDP-11/45; ULTRIX-11
  295. X#     DEC VAX-11/780; VMS 4.0
  296. X#     SUN 2/150; 4.2 BSD UNIX
  297. X#     Pyramid 90x; OSx 2.1
  298. X#     CoData 3300; Version 7 UniPlus+
  299. X#     Callan Unistar 200; System V UniPlus+
  300. X#     IBM PC/XT; Coherent
  301. X#     Intel 386; XENIX 3.0
  302. X#     CRDS Universe 68; UNOS
  303. X# 
  304. X# #O    organization name
  305. X# 
  306. X# This should be the full name of your organization, squeezed to fit
  307. X# inside 80 columns as necessary. Don't be afraid to abbreviate where
  308. X# the abbreviation would be clear to the entire world (say a famous
  309. X# institution like MIT or CERN), but beware of duplication (In USC the C
  310. X# could be either California or Carolina).
  311. X# 
  312. X# #C    contact person
  313. X# 
  314. X# This should be the full name (or names, separated by commas) of the
  315. X# person responsible for handling queries from the outside world about
  316. X# your machine.
  317. X# 
  318. X# #E    contact person's electronic address
  319. X# 
  320. X# This should be just a machine name, and a user name, like
  321. X# `ucbvax!fair'. It should not be a full path, since we will be able to
  322. X# generate a path to the given address from the data you're giving us.
  323. X# There is no problem with the machine name not being the same as the #N
  324. X# field (i.e. the contact `lives' on another machine at your site).
  325. X# 
  326. X# Also, it's a good idea to give a generic address or alias (if your
  327. X# mail system is capable of providing aliases) like `usenet' or
  328. X# `postmaster', so that if the contact person leaves the institution or
  329. X# is re-assigned to other duties, he doesn't keep getting mail about the
  330. X# system. In a perfect world, people would send notice to the UUCP
  331. X# Project, but in practice, they don't, so the data does get out of
  332. X# date. If you give a generic address you can easily change it to point
  333. X# at the appropriate person.
  334. X# 
  335. X# Multiple electronic addresses should be separated by commas, and all
  336. X# of them should be specified in the manner described above.
  337. X# 
  338. X# #T    contact person's telephone number
  339. X# 
  340. X# Format: +<country code><space><area code><space><prefix><space><number>
  341. X# 
  342. X# Example:
  343. X# 
  344. X# #T    +1 415 642 1024
  345. X# 
  346. X# This is the international format for the representation of phone
  347. X# numbers. The country code for the United States of America (and
  348. X# Canada) is 1. Other country codes should be listed in your telephone
  349. X# book.
  350. X# 
  351. X# If you must list an extension (i.e. what to ask the receptionist for,
  352. X# if not the name of the contact person), list it after the main phone
  353. X# number with an `x' in front of it to distinguish it from the rest of
  354. X# the phone number.
  355. X# 
  356. X# Example:
  357. X# 
  358. X# #T    +1 415 549 3854 x37
  359. X# 
  360. X# Multiple phone numbers should be separated by commas, and all of them
  361. X# should be completely specified as described above to prevent
  362. X# confusion.
  363. X# 
  364. X# #P      organization's address
  365. X# 
  366. X# This field should be one line filled with whatever else anyone would
  367. X# need after the contact person's name, and your organization's name
  368. X# (given in other fields above), to mail you something by paper mail.
  369. X# 
  370. X# #L      latitude and longitude
  371. X# 
  372. X# This should be in the following format:
  373. X# 
  374. X# #L    DD MM [SS] "N"|"S" / DDD MM [SS] "E"|"W" ["city"]
  375. X# 
  376. X# Two fields, with optional third.
  377. X# 
  378. X# First number is Latitude in degrees (NN), minutes (MM), and seconds
  379. X# (SS), and a N or S to indicate North or South of the Equator.
  380. X# 
  381. X# A Slash Separator.
  382. X# 
  383. X# Second number is Longitude in degrees (DDD), minutes (MM), and seconds
  384. X# (SS), and a E or W to indicate East or West of the Prime Meridian in
  385. X# Greenwich, England.
  386. X# 
  387. X# Seconds are optional, but it is worth noting that the more accurate
  388. X# you are, the more accurate maps we can make of the network (including
  389. X# blow-ups of various high density areas, like New Jersey, or the San
  390. X# Francisco Bay Area).
  391. X# 
  392. X# If you give the coordinates for your city (i.e. without fudging for
  393. X# where you are relative to that), add the word `city' at the end of the
  394. X# end of the specification, to indicate that. If you know where you are
  395. X# relative to a given coordinate for which you have longitude and
  396. X# latitude data, then the following fudge factors can be useful:
  397. X# 
  398. X# 1 degree    =    69.2 miles    =    111 kilometers
  399. X# 1 minute    =    1.15 miles    =    1.86 kilometers
  400. X# 1 second    =    102 feet    =    30.9 meters
  401. X#
  402. X# For LONGITUDE, multiply the above numbers by the cosine of your
  403. X# latitude.  For instance, at latitude 35 degrees, a degree of longitude
  404. X# is 69.2*0.819 = 56.7 miles; at latitude 40 degrees, it is 69.2*0.766 =
  405. X# 53.0 miles.  If you don't see why the measure of longitude depends on
  406. X# your latitude, just think of a globe, with all those N-S meridians of
  407. X# longitude converging on the poles.  You don't do this cosine
  408. X# multiplication for LATITUDE.
  409. X#
  410. X# Here is a short cosine table in case you don't have a trig calculator
  411. X# handy.  (But you can always write a short program in C.  The cosine
  412. X# function in bc(1) doesn't seem to work as documented.)
  413. X# deg  cos  deg  cos  deg  cos  deg  cos  deg  cos  deg  cos
  414. X#  0  1.000  5  0.996 10  0.985 15  0.966 20  0.940 25  0.906
  415. X# 30  0.866 35  0.819 40  0.766 45  0.707 50  0.643 55  0.574
  416. X# 60  0.500 65  0.423 70  0.342 75  0.259 80  0.174 85  0.087
  417. X# 
  418. X# The Prime Meridian is through Greenwich, England, and longitudes run
  419. X# from 180 degrees West of Greenwich to 180 East.  Latitudes run from
  420. X# 90 degrees North of the Equator to 90 degrees South.
  421. X# 
  422. X# #R      remarks
  423. X# 
  424. X# This is for one line of comment. As noted before, all lines beginning
  425. X# with a `#' character are comment lines, so if you need more than one
  426. X# line to tell us something about your site, do so between the end of the
  427. X# map data (the #?\t fields) and the pathalias data.
  428. X# 
  429. X# #U    netnews neighbors
  430. X# 
  431. X# The USENET is the network that moves netnews around, specifically,
  432. X# news.announce.important. If you send news.announce.important to any of
  433. X# your UUCP neighbors, list their names here, delimited by spaces.
  434. X# Example:
  435. X# 
  436. X# #U    ihnp4 decvax mcvax seismo
  437. X# 
  438. X# Since some places have lots of USENET neighbors, continuation lines
  439. X# should be just another #U and more site names.
  440. X# 
  441. X# #W      who last edited the entry and when
  442. X# 
  443. X# This field should contain an email address, a name in parentheses,
  444. X# followed by a semi-colon, and the output of the date program.
  445. X# Example:
  446. X# 
  447. X# #W    ucbvax!fair (Erik E. Fair); Sat Jun 22 03:35:16 PDT 1985
  448. X# 
  449. X# The same rules for email address that apply in the contact's email
  450. X# address apply here also. (i.e. only one system name, and user name).
  451. X# It is intended that this field be used for automatic ageing of the
  452. X# map entries so that we can do more automated checking and updating
  453. X# of the entire map. See getdate(3) from the netnews source for other
  454. X# acceptable date formats.
  455. X# 
  456. X# PATHALIAS DATA (or, documenting your UUCP connections & frequency of use)
  457. X# 
  458. X# The DEMAND, DAILY, etc., entries represent imaginary connect costs (see
  459. X# below) used by pathalias to calculate lowest cost paths.  The cost
  460. X# breakdown is:
  461. X# 
  462. X#     LOCAL        25    local area network
  463. X#     DEDICATED    95    high speed dedicated
  464. X#     DIRECT        200    local call
  465. X#     DEMAND          300     normal call (long distance, anytime)
  466. X#     HOURLY        500    hourly poll
  467. X#     EVENING        1800    time restricted call
  468. X#     DAILY        5000    daily poll
  469. X#     WEEKLY        30000    irregular poll
  470. X#     DEAD            a very high number - not usable path
  471. X# 
  472. X# Additionally, HIGH and LOW (used like DAILY+HIGH) are -5 and +5
  473. X# respectively, for baud-rate or quality bonuses/penalties.  Arithmetic
  474. X# expressions can be used, however, you should be aware that the results
  475. X# are often counter-intuitive (e.g. (DAILY*4) means every 4 days, not 4
  476. X# times a day).  This is because the numbers represent "cost of connection"
  477. X# rather than "frequency of connection."
  478. X# 
  479. X# The numbers are intended to represent cost of transferring mail over
  480. X# the link, measured very rougly in elapsed time, which seems to be
  481. X# far more important than baud rates for this type of
  482. X# traffic.  There is an assumed high overhead for each hop; thus,
  483. X# HOURLY is far more than DAILY/24.
  484. X# 
  485. X# There are a few other cost names that sometimes appear in the map.
  486. X# Some are synonyms for the preferred names above (e.g. POLLED is assumed
  487. X# to mean overnight and is taken to be the same as DAILY), some are
  488. X# obsolete (e.g.  the letters A through F, which are letter grades for
  489. X# connections.) It is not acceptable to make up new names or spellings
  490. X# (pathalias gets very upset when people do that...).
  491. X# 
  492. X# LOCAL AREA NETWORKS
  493. X# 
  494. X# We do not want local area network information in the published map.
  495. X# If you want to put your LAN in your local Path.* files, read about
  496. X# the LAN syntax in the pathalias.1 manual page.
  497. X# 
  498. X# WHAT TO DO WITH THIS STUFF
  499. X# 
  500. X# Once you have finished constructing your pathalias entry, mail it off
  501. X# to {uunet|gatech|ucsd|ames}!rutgers!uucpmap, which will be sent to the
  502. X# appropriate regional map coordinator.  They maintain assigned
  503. X# geographic sections of the map, and the entire map is posted on a
  504. X# rolling basis in the USENET newsgroups comp.mail.maps over the course
  505. X# of a month.
  506. X# 
  507. X# Questions or comments about this specification should also be directed
  508. X# at rutgers!uucpmap.
  509. X# 
  510. END_OF_FILE
  511. if test 18172 -ne `wc -c <'man/MAPS'`; then
  512.     echo shar: \"'man/MAPS'\" unpacked with wrong size!
  513. fi
  514. # end of 'man/MAPS'
  515. fi
  516. if test -f 'src/News060/rnews.c' -a "${1}" != "-c" ; then 
  517.   echo shar: Will not clobber existing file \"'src/News060/rnews.c'\"
  518. else
  519. echo shar: Extracting \"'src/News060/rnews.c'\" \(17361 characters\)
  520. sed "s/^X//" >'src/News060/rnews.c' <<'END_OF_FILE'
  521. X
  522. X/*
  523. X *  RNEWS.C
  524. X *
  525. X *  Copyright 1988 by William Loftus.  All rights reserved.
  526. X *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  527. X *
  528. X *  Version 0.60 Beta
  529. X *
  530. X *  This is rnews for compressed news.    News 2.11 will uux
  531. X *  a file to this system that will be in compressed format.
  532. X *  This program will strip off the "#! cunbatch", uncompress
  533. X *  the news, and call unbatch.  If the news is not in compressed
  534. X *  format it will just pass it to unbatch.
  535. X */
  536. X
  537. X#include <stdio.h>
  538. X#include <stdlib.h>
  539. X#include <string.h>
  540. X#include <log.h>
  541. X#include "/version.h"
  542. X#include <errno.h>
  543. X#include <ctype.h>
  544. X
  545. X#define MAXGROUPS   1024
  546. X
  547. XIDENT(".01");
  548. X
  549. Xvoid uncompress_news();
  550. Xvoid unbatch_news();
  551. Xvoid writeerr();
  552. Xvoid CreateDirsFor();
  553. Xchar *TmpFileName();
  554. X
  555. Xint    Compressed;
  556. Xchar    *SeqFile = "UULIB:SeqNews";
  557. Xchar    *TmpFile;
  558. X
  559. Xvoid
  560. Xmain (argc, argv)
  561. Xint argc;
  562. Xchar **argv;
  563. X{
  564. X    FILE *fp;
  565. X    char buf[32];
  566. X    int ch;
  567. X    int status = 0;
  568. X
  569. X    LogProgram = "RNews";
  570. X    TmpFile = TmpFileName("T:mail");
  571. X
  572. X    fclose(stderr);  /* Assume we are running in the background */
  573. X
  574. X    fgets(buf, 13, stdin);
  575. X
  576. X    if (!strncmp(buf,"#! cunbatch", 11)) {
  577. X    Compressed = 1;
  578. X    } else if (!strncmp(buf,"#! rnews", 8)) {
  579. X    fp = fopen(TmpFile, "w");
  580. X    if (fp == (char *)NULL) {
  581. X        ulog(-1, "Unable to open %s for output", TmpFile);
  582. X        exit(1);
  583. X    }
  584. X    fprintf(fp, "%s\n",  buf);
  585. X    while ((ch = getchar()) != EOF) {
  586. X        fputc(ch, fp);
  587. X    }
  588. X    fclose(fp);
  589. X    Compressed = 0;
  590. X    } else {
  591. X    ulog(-1, "News in wrong format");
  592. X    remove(TmpFile);
  593. X    exit(1);
  594. X    }
  595. X
  596. X    if (Compressed) {
  597. X    uncompress_news();
  598. X    }
  599. X
  600. X    unbatch_news();
  601. X
  602. X    status = remove(TmpFile);
  603. X
  604. X    if (status != 0) {
  605. X    ulog(-1, "Unable to remove %s", TmpFile);
  606. X    exit(1);
  607. X    }
  608. X}
  609. X
  610. X/*
  611. X * Unbatch, an Amiga unbatcher.
  612. X *
  613. X *  Written by Fred Cassirer, 10/8/88.
  614. X *  Some unbatch code originally taken from News2.11 sources.
  615. X *
  616. X *  Ported to Lattice 5.0
  617. X *  Added config.h file
  618. X *  Added use of ERRORFILE
  619. X *  11/23/1988    Dan 'Sneakers' Schein
  620. X *
  621. X * This code (as well as the unbatch stuff) is free for anyone who thinks
  622. X * they can get some use out of it.
  623. X *
  624. X *  Articles will only
  625. X *  be placed in newsgroups as defined in the "UULIB:NewsGroups"
  626. X *  control file.  Articles which are not listed in the control file
  627. X *  are placed in the "Reject" directory.  Articles are sequenced by
  628. X *  the sequencer in "UULIB:seqnews". This could possibly be updated
  629. X *  to use a sequencer within each of the subdirectories, to more closely
  630. X *  resemble the News system under Unix.
  631. X *
  632. X *  Unbatch will also take command line args of files to be unbatched.
  633. X *  Files on the command line are not removed, they should be removed
  634. X *  after running unbatch.
  635. X */
  636. X
  637. Xstatic char *groups[MAXGROUPS];
  638. X
  639. Xvoid
  640. Xunbatch_news()
  641. X{
  642. X    if (!freopen(TmpFile, "r", stdin)) {
  643. X    ulog(-1, "Can't unbatch, expected file %s to exist", TmpFile);
  644. X    exit(1);
  645. X    }
  646. X    if (unbatch())
  647. X    ulog(-1, "Unbatch failed");
  648. X    fclose(stdin);
  649. X}
  650. X
  651. X
  652. Xvoid
  653. Xinitgroups(newsgroups)
  654. Xchar *newsgroups;
  655. X{
  656. X    static char buf[BUFSIZ];
  657. X    static int initflag = 0;
  658. X    int i, len;
  659. X    FILE *fp;
  660. X
  661. X    if (initflag)
  662. X    return;
  663. X
  664. X    initflag = 1;
  665. X
  666. X    if ((fp = fopen(newsgroups, "r")) == NULL)  {
  667. X    ulog(-1, "Unable to open newsgroup file %s", newsgroups);
  668. X    remove(TmpFile);
  669. X    exit(2);
  670. X    }
  671. X
  672. X    i = 0;
  673. X    while (fgets(buf, BUFSIZ, fp) && (i < MAXGROUPS)) {
  674. X    len = strlen(buf) - 1;
  675. X    buf[len] = '\0';
  676. X    if ((groups[i] = malloc(len+1)) == NULL) {
  677. X        ulog(-1, "malloc failed");
  678. X        remove(TmpFile);
  679. X        exit(4);
  680. X    }
  681. X    strcpy(groups[i], buf);
  682. X    i++;
  683. X    }
  684. X    groups[i] = NULL;
  685. X    fclose(fp);
  686. X}
  687. X
  688. Xchar *
  689. Xfinddir(dir)
  690. Xchar *dir;
  691. X{
  692. X    static char work[40];
  693. X    char *p;
  694. X    int i;
  695. X
  696. X    while (1) {
  697. X    p = work;
  698. X    while ((*dir != ' ') && (*dir != ',') && *dir)
  699. X        *p++ = *dir++;
  700. X
  701. X    *p = '\0';
  702. X    for (i = 0; groups[i] != NULL; ++i) {
  703. X        if (strcmpi(groups[i], work) == 0)
  704. X        return(work);
  705. X    }
  706. X
  707. X    if (!*dir++)
  708. X        break;
  709. X    }
  710. X    return(NULL);
  711. X}
  712. X
  713. X/*
  714. X * unbatchnews: extract news in batched format and process it one article
  715. X * at a time.  The format looks like
  716. X *    #! rnews 1234
  717. X *    article containing 1234 characters
  718. X *    #! rnews 4321
  719. X *    article containing 4321 characters
  720. X *
  721. X *    or
  722. X *
  723. X *    #! command [args]
  724. X *    calls LIBDIR/command [args] to process the news
  725. X */
  726. X
  727. X#define MAXARGS     20
  728. X#define FILES_PER_LINE    5
  729. X
  730. Xchar buf[BUFSIZ];
  731. Xchar homedir[128];
  732. X
  733. Xunbatch()
  734. X{
  735. X    int c;
  736. X    FILE *pfn;
  737. X    long size;
  738. X    FILE *seq;
  739. X    char filename[128], tmpname[30];
  740. X    int  seqno, fcount;
  741. X    long atol();
  742. X    char *dir;
  743. X
  744. X    initgroups("UULIB:Newsgroups");
  745. X
  746. X    if ((seq = fopen(SeqFile, "r")) != NULL) {
  747. X    fscanf(seq,"%d",&seqno);
  748. X    fclose(seq);
  749. X    } else {
  750. X    ulog(-1, "Sequence file %s not found, creating", SeqFile);
  751. X    seqno = 0;
  752. X    }
  753. X
  754. X    if (gets(buf) == NULL) {
  755. X    ulog(-1, "Empty file!");
  756. X    return(2);
  757. X    }
  758. X
  759. X    if (strncmp(buf, "#! rnews ", 9) != 0) {
  760. X    ulog(-1, "unbatch: rnews cmd not supported '%s'!", buf);
  761. X    return(1);
  762. X    }
  763. X
  764. X    fcount = 0;
  765. X    do {
  766. X    if (!fcount) {
  767. X        fflush(stdout);
  768. X        fcount = FILES_PER_LINE;
  769. X    }
  770. X    while (strncmp(buf, "#! rnews ", 9) && strncmp(buf, "! rnews ", 8)) { /* kludge for bug */
  771. X        char *cp;
  772. X        for (cp = buf; *cp != '\0'; ++cp) {
  773. X        if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp)))
  774. X            *cp = '?';
  775. X        }
  776. X        ulog(-1, "out of sync, skipping %s", buf);
  777. X        if (gets(buf) == NULL)
  778. X        return(0);
  779. X    }
  780. X
  781. X    size = atol(buf + (buf[0] == '#' ? 9 : 8));
  782. X    if (size <= 0) {
  783. X        ulog(-1, "nonsense size %ld", size);
  784. X        continue;
  785. X    }
  786. X
  787. X    sprintf(tmpname,"UUNEWS:Tmp%d", ++seqno);
  788. X    fcount--;
  789. X    fflush(stdout);
  790. X    if ((pfn = fopen(tmpname, "w")) == NULL) {
  791. X        ulog(-1, "Can't create %s", tmpname);
  792. X        exit(3);
  793. X    }
  794. X
  795. X    while (gets(buf)) {
  796. X        fprintf(pfn, "%s\n", buf);
  797. X        size -= strlen(buf) + 1;
  798. X        if (strncmp(buf, "Newsgroup", 9) == 0) {
  799. X        if (!(dir = finddir(buf+12))) {
  800. X            ulog(-1, "Articles for %s placed in Rejects", buf+12);
  801. X            dir = "Rejects";
  802. X        }
  803. X        sprintf(filename, "UUNEWS:%s/%d", dir, seqno);
  804. X        break; /* Get out of the while */
  805. X        }
  806. X    }
  807. X
  808. X    if (size > 0) {
  809. X        while(--size >= 0 && (c = getc(stdin)) != EOF)
  810. X        putc(c, pfn);
  811. X        if (ferror(pfn) || fclose(pfn)) {   /* disk full? */
  812. X        ulog(-1, "Error writing to temp file");
  813. X        break;
  814. X        }
  815. X        if (rename(tmpname, filename) < 0) {
  816. X        CreateDirsFor(filename);
  817. X        rename(tmpname, filename);
  818. X        }
  819. X    }
  820. X
  821. X       /*
  822. X    * If we got a truncated batch, don't process the
  823. X    * last article; it will probably be received again.
  824. X    */
  825. X
  826. X    if (size > 0) {
  827. X        ulog(-1, "truncated batch");
  828. X        break;
  829. X    }
  830. X    } while (gets(buf) != NULL);
  831. X
  832. X    if ((seq = fopen(SeqFile, "w")) == NULL) {
  833. X    ulog(-1, "Unable to create %s", SeqFile);
  834. X    }
  835. X    fprintf(seq, "%d\n", seqno);
  836. X    fclose(seq);
  837. X    return(0);
  838. X}
  839. X
  840. Xint
  841. XSystem(cmd)
  842. Xchar *cmd;
  843. X{
  844. X    long nl;
  845. X    int return_value;
  846. X
  847. X    if ((nl = (long)Open("null:wpl", 1006)) != NULL) {
  848. X    return_value = (Execute(cmd, nl, nl) == -1) ? 0 : -1;
  849. X    Close(nl);
  850. X    } else {
  851. X    ulog(-1, "Unable to open NULL: device, did you mount it?");
  852. X    return_value = -1;
  853. X    }
  854. X    return return_value;
  855. X}
  856. X
  857. X
  858. X/*
  859. X * Set USERMEM to the maximum amount of physical user memory available
  860. X * in bytes.  USERMEM is used to determine the maximum BITS that can be used
  861. X * for compression.
  862. X *
  863. X * SACREDMEM is the amount of physical memory saved for others; compress
  864. X * will hog the rest.
  865. X */
  866. X#ifndef SACREDMEM
  867. X#define SACREDMEM    0
  868. X#endif
  869. X
  870. X#ifndef USERMEM
  871. X/*# ifdef AMIGA
  872. X#   define USERMEM    200000
  873. X# else*/
  874. X#   define USERMEM    450000    /* default user memory */
  875. X/* # endif*/
  876. X#endif
  877. X
  878. X#ifdef interdata        /* (Perkin-Elmer) */
  879. X#define SIGNED_COMPARE_SLOW    /* signed compare is slower than unsigned */
  880. X#endif
  881. X
  882. X#ifdef pdp11
  883. X# define BITS    12    /* max bits/code for 16-bit machine */
  884. X# define NO_UCHAR    /* also if "unsigned char" functions as signed char */
  885. X# undef USERMEM
  886. X#endif /* pdp11 */    /* don't forget to compile with -i */
  887. X
  888. X#ifdef z8000
  889. X# define BITS    12
  890. X# undef vax        /* weird preprocessor */
  891. X# undef USERMEM
  892. X#endif /* z8000 */
  893. X
  894. X#ifdef pcxt
  895. X# define BITS    12
  896. X# undef USERMEM
  897. X#endif /* pcxt */
  898. X
  899. X#ifdef USERMEM
  900. X# if USERMEM >= (433484+SACREDMEM)
  901. X#  define PBITS 16
  902. X# else
  903. X#  if USERMEM >= (229600+SACREDMEM)
  904. X#   define PBITS    15
  905. X#  else
  906. X#   if USERMEM >= (127536+SACREDMEM)
  907. X#    define PBITS    14
  908. X#   else
  909. X#    if USERMEM >= (73464+SACREDMEM)
  910. X#     define PBITS    13
  911. X#    else
  912. X#     define PBITS    12
  913. X#    endif
  914. X#   endif
  915. X#  endif
  916. X# endif
  917. X# undef USERMEM
  918. X#endif /* USERMEM */
  919. X
  920. X#ifdef PBITS        /* Preferred BITS for this memory size */
  921. X# ifndef BITS
  922. X#  define BITS PBITS
  923. X# endif BITS
  924. X#endif /* PBITS */
  925. X
  926. X#if BITS == 16
  927. X# define HSIZE    69001        /* 95% occupancy */
  928. X#endif
  929. X#if BITS == 15
  930. X# define HSIZE    35023        /* 94% occupancy */
  931. X#endif
  932. X#if BITS == 14
  933. X# define HSIZE    18013        /* 91% occupancy */
  934. X#endif
  935. X#if BITS == 13
  936. X# define HSIZE    9001        /* 91% occupancy */
  937. X#endif
  938. X#if BITS <= 12
  939. X# define HSIZE    5003        /* 80% occupancy */
  940. X#endif
  941. X
  942. X#ifdef M_XENIX            /* Stupid compiler can't handle arrays with */
  943. X# if BITS == 16         /* more than 65535 bytes - so we fake it */
  944. X#  define XENIX_16
  945. X# else
  946. X#  if BITS > 13         /* Code only handles BITS = 12, 13, or 16 */
  947. X#   define BITS 13
  948. X#  endif
  949. X# endif
  950. X#endif
  951. X
  952. X/*
  953. X * a code_int must be able to hold 2**BITS values of type int, and also -1
  954. X */
  955. X#if BITS > 15
  956. Xtypedef long int    code_int;
  957. X#else
  958. Xtypedef int        code_int;
  959. X#endif
  960. X
  961. X#ifdef SIGNED_COMPARE_SLOW
  962. Xtypedef unsigned long int count_int;
  963. Xtypedef unsigned short int count_short;
  964. X#else
  965. Xtypedef long int      count_int;
  966. X#endif
  967. X
  968. X#ifdef NO_UCHAR
  969. X typedef char    char_type;
  970. X#else
  971. X typedef    unsigned char    char_type;
  972. X#endif /* UCHAR */
  973. Xchar_type magic_header[] = { "\037\235" };      /* 1F 9D */
  974. X
  975. X/* Defines for third byte of header */
  976. X#define BIT_MASK    0x1f
  977. X#define BLOCK_MASK    0x80
  978. X/* Masks 0x40 and 0x20 are free.  I think 0x20 should mean that there is
  979. X   a fourth header byte (for expansion).
  980. X*/
  981. X#define INIT_BITS 9            /* initial number of bits/code */
  982. X
  983. X#include <stdio.h>
  984. X#include <ctype.h>
  985. X
  986. Xint n_bits;                /* number of bits/code */
  987. Xint maxbits = BITS;            /* user settable max # bits/code */
  988. Xcode_int maxcode;            /* maximum code, given n_bits */
  989. Xcode_int maxmaxcode = 1 << BITS;    /* should NEVER generate this code */
  990. X#define MAXCODE(n_bits)        ((1 << (n_bits)) - 1)
  991. X
  992. Xcount_int htab [HSIZE];
  993. Xunsigned short codetab [HSIZE];
  994. X#define htabof(i)       htab[i]
  995. X#define codetabof(i)    codetab[i]
  996. Xcode_int hsize = HSIZE;         /* for dynamic table sizing */
  997. Xcount_int fsize;
  998. X
  999. X/*
  1000. X * To save much memory, we overlay the table used by compress() with those
  1001. X * used by decompress().  The tab_prefix table is the same size and type
  1002. X * as the codetab.  The tab_suffix table needs 2**BITS characters.  We
  1003. X * get this from the beginning of htab.  The output stack uses the rest
  1004. X * of htab, and contains characters.  There is plenty of room for any
  1005. X * possible stack (stack used to be 8000 characters).
  1006. X */
  1007. X
  1008. X#define tab_prefixof(i) codetabof(i)
  1009. X#define tab_suffixof(i)        (((char_type *)htab)[i])
  1010. X#define tab_suffixof1(i)        (((long)htab)+(long)(i))
  1011. X#define de_stack           (char_type *)(tab_suffixof1(1<<BITS))
  1012. X
  1013. Xcode_int free_ent = 0;            /* first unused entry */
  1014. Xint exit_stat = 0;
  1015. X
  1016. Xcode_int getcode();
  1017. X
  1018. Xvoid _fprintf() { }
  1019. X
  1020. Xint nomagic = 0;    /* Use a 3-byte magic number header, unless old file */
  1021. X
  1022. X/*
  1023. X * block compression parameters -- after all codes are used up,
  1024. X * and compression rate changes, start over.
  1025. X */
  1026. Xint block_compress = BLOCK_MASK;
  1027. Xint clear_flg = 0;
  1028. Xlong int ratio = 0;
  1029. X#define CHECK_GAP 10000 /* ratio check interval */
  1030. Xcount_int checkpoint = CHECK_GAP;
  1031. X/*
  1032. X * the next two codes should not be changed lightly, as they must not
  1033. X * lie within the contiguous general code space.
  1034. X */
  1035. X#define FIRST    257    /* first free entry */
  1036. X#define CLEAR    256    /* table clear output code */
  1037. X
  1038. Xint (*bgnd_flag)();
  1039. X
  1040. Xstatic void decompress ();
  1041. Xstatic void compress ();
  1042. X
  1043. Xvoid
  1044. Xuncompress_news()
  1045. X{
  1046. X    if (freopen(TmpFile, "w", stdout) == NULL) {
  1047. X       ulog(-1, "Can't open uncompressed file %s", TmpFile);
  1048. X       exit(1);
  1049. X    }
  1050. X
  1051. X    maxbits = BITS;
  1052. X    maxmaxcode = 1 << maxbits;
  1053. X
  1054. X    /* Check the magic number */
  1055. X    if (nomagic == 0) {
  1056. X       if ((getchar()!=(magic_header[0] & 0xFF))
  1057. X      || (getchar()!=(magic_header[1] & 0xFF))) {
  1058. X        ulog(-1, "stdin: not in compressed format");
  1059. X        exit(1);
  1060. X    }
  1061. X    maxbits = getchar();    /* set -b from file */
  1062. X    block_compress = maxbits & BLOCK_MASK;
  1063. X    maxbits &= BIT_MASK;
  1064. X    maxmaxcode = 1 << maxbits;
  1065. X    fsize = 100000;     /* assume stdin large for USERMEM */
  1066. X    }
  1067. X  decompress();
  1068. X
  1069. X  fclose(stdout);
  1070. X}
  1071. X
  1072. Xstatic int offset;
  1073. Xlong int in_count = 1;            /* length of input */
  1074. Xlong int bytes_out;            /* length of compressed output */
  1075. Xlong int out_count = 0;         /* # of codes output (for debugging) */
  1076. X
  1077. X
  1078. X/*
  1079. X * Decompress stdin to stdout.    This routine adapts to the codes in the
  1080. X * file building the "string" table on-the-fly; requiring no table to
  1081. X * be stored in the compressed file.  The tables used herein are shared
  1082. X * with those of the compress() routine.  See the definitions above.
  1083. X */
  1084. X
  1085. Xstatic void decompress() {
  1086. X    register char_type *stackp;
  1087. X    register int finchar;
  1088. X    register code_int code, oldcode, incode;
  1089. X
  1090. X    /*
  1091. X     * As above, initialize the first 256 entries in the table.
  1092. X     */
  1093. X    maxcode = MAXCODE(n_bits = INIT_BITS);
  1094. X    for ( code = 255; code >= 0; code-- ) {
  1095. X    tab_prefixof(code) = 0;
  1096. X    tab_suffixof(code) = (char_type)code;
  1097. X    }
  1098. X    free_ent = ((block_compress) ? FIRST : 256 );
  1099. X
  1100. X    finchar = oldcode = getcode();
  1101. X    if(oldcode == -1)   /* EOF already? */
  1102. X    return;         /* Get out of here */
  1103. X    putchar( (char)finchar );   /* first code must be 8 bits = char */
  1104. X    if(ferror(stdout))          /* Crash if can't write */
  1105. X    writeerr();
  1106. X    stackp = de_stack;
  1107. X
  1108. X    while ( (code = getcode()) > -1 ) {
  1109. X
  1110. X    if ( (code == CLEAR) && block_compress ) {
  1111. X        for ( code = 255; code >= 0; code-- )
  1112. X        tab_prefixof(code) = 0;
  1113. X        clear_flg = 1;
  1114. X        free_ent = FIRST - 1;
  1115. X        if ( (code = getcode ()) == -1 )    /* O, untimely death! */
  1116. X        break;
  1117. X    }
  1118. X    incode = code;
  1119. X    /*
  1120. X     * Special case for KwKwK string.
  1121. X     */
  1122. X    if ( code >= free_ent ) {
  1123. X        *stackp++ = finchar;
  1124. X        code = oldcode;
  1125. X    }
  1126. X
  1127. X    /*
  1128. X     * Generate output characters in reverse order
  1129. X     */
  1130. X#ifdef SIGNED_COMPARE_SLOW
  1131. X    while ( ((unsigned long)code) >= ((unsigned long)256) ) {
  1132. X#else
  1133. X    while ( code >= 256 ) {
  1134. X#endif
  1135. X        *stackp++ = tab_suffixof(code);
  1136. X        code = tab_prefixof(code);
  1137. X    }
  1138. X    *stackp++ = finchar = tab_suffixof(code);
  1139. X
  1140. X    /*
  1141. X     * And put them out in forward order
  1142. X     */
  1143. X    do
  1144. X        putchar ( *--stackp );
  1145. X    while ( stackp > de_stack );
  1146. X
  1147. X    /*
  1148. X     * Generate the new entry.
  1149. X     */
  1150. X    if ( (code=free_ent) < maxmaxcode ) {
  1151. X        tab_prefixof(code) = (unsigned short)oldcode;
  1152. X        tab_suffixof(code) = finchar;
  1153. X        free_ent = code+1;
  1154. X    }
  1155. X    /*
  1156. X     * Remember previous code.
  1157. X     */
  1158. X    oldcode = incode;
  1159. X    }
  1160. X
  1161. X    fflush( stdout );
  1162. X    if(ferror(stdout))
  1163. X    writeerr();
  1164. X}
  1165. X
  1166. Xchar_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
  1167. Xchar_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
  1168. X
  1169. X/*****************************************************************
  1170. X * TAG( getcode )
  1171. X *
  1172. X * Read one code from the standard input.  If EOF, return -1.
  1173. X * Inputs:
  1174. X *    stdin
  1175. X * Outputs:
  1176. X *    code or -1 is returned.
  1177. X */
  1178. X
  1179. Xcode_int
  1180. Xgetcode() {
  1181. X    /*
  1182. X     * On the VAX, it is important to have the register declarations
  1183. X     * in exactly the order given, or the asm will break.
  1184. X     */
  1185. X    register code_int code;
  1186. X    static int offset = 0, size = 0;
  1187. X    static char_type buf[BITS];
  1188. X    register int r_off, bits;
  1189. X    register char_type *bp = buf;
  1190. X
  1191. X    if ( clear_flg > 0 || offset >= size || free_ent > maxcode ) {
  1192. X    /*
  1193. X     * If the next entry will be too big for the current code
  1194. X     * size, then we must increase the size.  This implies reading
  1195. X     * a new buffer full, too.
  1196. X     */
  1197. X    if ( free_ent > maxcode ) {
  1198. X        n_bits++;
  1199. X        if ( n_bits == maxbits )
  1200. X        maxcode = maxmaxcode;    /* won't get any bigger now */
  1201. X        else
  1202. X        maxcode = MAXCODE(n_bits);
  1203. X    }
  1204. X    if ( clear_flg > 0) {
  1205. X        maxcode = MAXCODE (n_bits = INIT_BITS);
  1206. X        clear_flg = 0;
  1207. X    }
  1208. X    size = fread( buf, 1, n_bits, stdin );
  1209. X    if ( size <= 0 )
  1210. X        return -1;            /* end of file */
  1211. X    offset = 0;
  1212. X    /* Round size down to integral number of codes */
  1213. X    size = (size << 3) - (n_bits - 1);
  1214. X    }
  1215. X    r_off = offset;
  1216. X    bits = n_bits;
  1217. X    /*
  1218. X     * Get to the first byte.
  1219. X     */
  1220. X    bp += (r_off >> 3);
  1221. X    r_off &= 7;
  1222. X    /* Get first part (low order bits) */
  1223. X#ifdef NO_UCHAR
  1224. X    code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
  1225. X#else
  1226. X    code = (*bp++ >> r_off);
  1227. X#endif /* NO_UCHAR */
  1228. X    bits -= (8 - r_off);
  1229. X    r_off = 8 - r_off;        /* now, offset into code word */
  1230. X    /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
  1231. X    if ( bits >= 8 ) {
  1232. X#ifdef NO_UCHAR
  1233. X        code |= (*bp++ & 0xff) << r_off;
  1234. X#else
  1235. X        code |= *bp++ << r_off;
  1236. X#endif /* NO_UCHAR */
  1237. X        r_off += 8;
  1238. X        bits -= 8;
  1239. X    }
  1240. X    /* high order bits. */
  1241. X    code |= (*bp & rmask[bits]) << r_off;
  1242. X    offset += n_bits;
  1243. X
  1244. X    return code;
  1245. X}
  1246. X
  1247. Xchar *
  1248. Xrindex(s, c)            /* For those who don't have it in libc.a */
  1249. Xchar *s, c;
  1250. X{
  1251. X    char *p;
  1252. X    for (p = NULL; *s; s++)
  1253. X    if (*s == c)
  1254. X        p = s;
  1255. X    return(p);
  1256. X}
  1257. X
  1258. Xvoid
  1259. Xwriteerr()
  1260. X{
  1261. X    perror ( TmpFile );
  1262. X    unlink ( TmpFile );
  1263. X    exit ( 1 );
  1264. X}
  1265. X
  1266. X/*
  1267. X *  assign:path/path/path.../filename
  1268. X *
  1269. X *  creates path directories
  1270. X */
  1271. X
  1272. Xvoid
  1273. XCreateDirsFor(filename)
  1274. Xchar *filename;
  1275. X{
  1276. X    short i;
  1277. X    short j;
  1278. X
  1279. X    for (i = 0; ; ++i) {
  1280. X    for (j = i; filename[j] && filename[j] != ':' && filename[j] != '/'; ++j);
  1281. X    if (filename[j] == 0)
  1282. X        break;
  1283. X    if (filename[j] == ':') {
  1284. X        i = j;
  1285. X        continue;
  1286. X    }
  1287. X    filename[j] = 0;
  1288. X    mkdir(filename);        /*  may fail if parents already exist */
  1289. X    filename[j] = '/';
  1290. X    }
  1291. X}
  1292. X
  1293. END_OF_FILE
  1294. if test 17361 -ne `wc -c <'src/News060/rnews.c'`; then
  1295.     echo shar: \"'src/News060/rnews.c'\" unpacked with wrong size!
  1296. fi
  1297. # end of 'src/News060/rnews.c'
  1298. fi
  1299. if test -f 'src/getty/getty.c' -a "${1}" != "-c" ; then 
  1300.   echo shar: Will not clobber existing file \"'src/getty/getty.c'\"
  1301. else
  1302. echo shar: Extracting \"'src/getty/getty.c'\" \(19742 characters\)
  1303. sed "s/^X//" >'src/getty/getty.c' <<'END_OF_FILE'
  1304. X
  1305. X/*
  1306. X *  GETTY.C
  1307. X *
  1308. X *  (c)Copyright 1989, Matthew Dillon, All Rights Reserved
  1309. X *
  1310. X *  Uses:
  1311. X *    GETTY:PASSWD
  1312. X *    GETTY:LOGFILE
  1313. X *    GETTY:Getty-Header
  1314. X *
  1315. X *  GETTY   <options>    <modem-commands>
  1316. X *
  1317. X *    -Sdevicenam Tells GETTY which serial.device to use, default
  1318. X *            serial.device
  1319. X *
  1320. X *    -Uunitnum   Tells GETTY which unit number to use, default 0
  1321. X *
  1322. X *    -A        Always talk to the modem at the first baud
  1323. X *            rate in the -B list and ignore the baud rate
  1324. X *            in the CONNECT message.
  1325. X *
  1326. X *    -7        use SERF_7WIRE while online.
  1327. X *
  1328. X *    -Bn        Set baud rate.  If specified multiple times the
  1329. X *            first one is the default and remaining ones
  1330. X *            switched to when a BREAK is received after a
  1331. X *            connect.  Also determines how CONNECT messages
  1332. X *            are interpreted.  A CONNECT with no number uses
  1333. X *            the first -B entry while CONNECTs with numbers
  1334. X *            use those numbers regardless of any -B entries.
  1335. X *
  1336. X *    -Mc        Set modem type:
  1337. X *            c = m    = multimodem
  1338. X *                h    = hays
  1339. X *                d    = dumb (no AT or +++ cmds are ever sent),
  1340. X *                  normally used with only one specified
  1341. X *                  baud rate.
  1342. X *
  1343. X *    -m1        Turn on the modem speaker during dialing/connect
  1344. X *            (default is -m0)
  1345. X *
  1346. X *    -h0        Ignore CD (carrier detect), default is to use
  1347. X *            carrier detect.
  1348. X *
  1349. X *    -c0        Ignore CONNECT message (i.e. you are not connected
  1350. X *            to a modem, usually combined with -h0).  Default is
  1351. X *            to expect a CONNECT message.
  1352. X *
  1353. X *    -d0        do not use DTR to drop connection.    Default is
  1354. X *            to drop DTR to drop a connection.  If this option
  1355. X *            is chosen the +++ and ATH0 sequence will be used
  1356. X *            to drop a connection.
  1357. X *
  1358. X *    -xn        Set debug level.  Also causes log output to go
  1359. X *            to stdout instead of GETTY:LOGFILE
  1360. X *
  1361. X *    -0        QUIT - Kills any running getty for the specified
  1362. X *            port.
  1363. X *
  1364. X *    Any fields specified without a '-' are considered modem commands
  1365. X *    used to initialize/reinitialize the modem.  Up to 16 fields may
  1366. X *    be specified (each is sent to the modem in 1 second intervals)
  1367. X */
  1368. X
  1369. X#include <exec/types.h>
  1370. X#include <exec/lists.h>
  1371. X#include <exec/devices.h>
  1372. X#include <devices/timer.h>
  1373. X#include <devices/serial.h>
  1374. X#include <libraries/dos.h>
  1375. X#include <libraries/dosextens.h>
  1376. X#include <hardware/cia.h>
  1377. X#include <stdio.h>
  1378. X#include <stdlib.h>
  1379. X#include <proto/all.h>
  1380. X#include <pwd.h>
  1381. X#include "/version.h"
  1382. X
  1383. X#include "log.h"
  1384. X
  1385. XIDENT(".01");
  1386. X
  1387. X#define arysize(ary)    (sizeof(ary)/sizeof((ary)[0]))
  1388. X
  1389. X#define ST_WAITCD    0
  1390. X#define ST_CONNECT    1
  1391. X#define ST_LOGIN    2
  1392. X#define ST_PASSWD    3
  1393. X#define ST_RUN        4
  1394. X
  1395. Xtypedef struct IORequest    IOR;
  1396. Xtypedef struct timerequest  IOT;
  1397. Xtypedef struct IOExtSer     IOSER;
  1398. Xtypedef struct MsgPort        PORT;
  1399. Xtypedef struct List        LIST;
  1400. Xtypedef struct Node        NODE;
  1401. Xtypedef struct Message        MSG;
  1402. X
  1403. Xtypedef struct GMsg {
  1404. X    struct Message  Msg;
  1405. X    short   Cmd;
  1406. X    long    Data1;
  1407. X    void    *Data2;
  1408. X} GMsg;
  1409. X
  1410. Xextern struct ProcID *RunPasswdEntry();
  1411. X
  1412. Xchar    *CopyRight = "(c)Copyright 1989, Matthew Dillon, All Rights Reserved\r\n";
  1413. Xchar    *ComPortName;
  1414. X
  1415. Xchar    *DeviceName = "serial.device";
  1416. Xlong    DeviceUnit  = 0;
  1417. Xlong    NullFH;
  1418. Xchar    SpeakerLevel    = 0;
  1419. Xchar    AnswerRing    = 2;    /*  default, answer on second ring */
  1420. Xchar    SpeakerOpt    = 0;
  1421. Xchar    IgnoreCD    = 0;
  1422. Xchar    IgnoreConnect    = 0;
  1423. Xchar    IgnoreDTR    = 0;
  1424. Xchar    BaudAdjust    = 0;
  1425. Xchar    DropOnExit    = 1;
  1426. Xchar    ModemType    = 'h';
  1427. Xchar    ZeroOption    = 0;
  1428. Xchar    Wire7        = 0;        /*  use 7 wire while online */
  1429. Xchar    Locked        = 0;        /*  serial port is lcked    */
  1430. Xlong    Bauds[16] = { 9600 };        /*  up 16 baud rates        */
  1431. Xchar    *AtFields[16];
  1432. X
  1433. XPORT    *ComPort;
  1434. XPORT    *IoSink;    /*  Sink for IO reqs.    */
  1435. Xlong    IoSinkMask;
  1436. Xlong    ComPortMask;
  1437. X
  1438. XIOT    Iot;        /*  check-carrier    */
  1439. XIOSER    Iosr;        /*  serial read-req    */
  1440. XIOSER    Iosw;        /*  serial write-req    */
  1441. X
  1442. Xchar    IotIP;        /*  Iot0 in progress    */
  1443. Xchar    IosrIP;
  1444. X
  1445. Xchar    ScrBuf[256];
  1446. Xchar    ConnectBuf[64];
  1447. Xchar    LoginBuf[32];
  1448. Xchar    PasswdBuf[32];
  1449. Xchar    RxBuf[32];
  1450. Xchar    HaveConnectMsg;
  1451. Xchar    HaveLogin;
  1452. Xchar    HavePasswd;
  1453. X
  1454. Xshort    State;
  1455. Xshort    Index;
  1456. Xshort    BIndex;
  1457. X
  1458. Xshort CountDown;
  1459. Xshort GotOffPort;
  1460. X
  1461. Xvoid    SerPuts();
  1462. Xvoid    Set7Wire();
  1463. Xvoid    xexit();
  1464. Xvoid    Disconnect();
  1465. Xvoid    ClearRecv();
  1466. Xvoid    InitModem();
  1467. Xvoid    SetParams();
  1468. Xvoid    DoOptions();
  1469. Xvoid    SerialOff();
  1470. X
  1471. XCXBRK()
  1472. X{
  1473. X    return(0);
  1474. X}
  1475. X
  1476. Xmain(ac, av)
  1477. Xchar *av[];
  1478. X{
  1479. X    extern int IAmGetty;
  1480. X
  1481. X    IAmGetty = 1;    /*  for LockSerialPort()/UnLockSerialPort()   */
  1482. X
  1483. X    puts(CopyRight);
  1484. X    fflush(stdout);
  1485. X
  1486. X    LogProgram = "Getty";
  1487. X    LogWho = LoginBuf;
  1488. X    LogFile = "Getty:LOGFILE";
  1489. X    PasswdFile = "Getty:Passwd";
  1490. X
  1491. X    DoOptions(ac, av);
  1492. X
  1493. X    IoSink = CreatePort(NULL, 0);
  1494. X    IoSinkMask = 1 << IoSink->mp_SigBit;
  1495. X
  1496. X    ComPortName = malloc(strlen(DeviceName) + 20);
  1497. X    sprintf(ComPortName, "Getty.%s.%d", DeviceName, DeviceUnit);
  1498. X
  1499. X    Forbid();
  1500. X    if (ComPort = FindPort(ComPortName)) {
  1501. X    GMsg msg;
  1502. X    msg.Cmd = 'O';
  1503. X    msg.Data1 = ac;
  1504. X    msg.Data2 = (void *)av;
  1505. X    msg.Msg.mn_ReplyPort = IoSink;
  1506. X    PutMsg(ComPort, &msg.Msg);
  1507. X    WaitPort(IoSink);
  1508. X    Remove(&msg);
  1509. X    Permit();
  1510. X    puts("Options updated");
  1511. X    xexit(0);
  1512. X    }
  1513. X    ComPort = CreatePort(ComPortName, 0);
  1514. X    Permit();
  1515. X
  1516. X    ComPortMask = 1 << ComPort->mp_SigBit;
  1517. X
  1518. X    NullFH = Open("NULL:", 1006);
  1519. X    if (NullFH == NULL) {
  1520. X    ulog(-1, "GETTY REQUIRES NULL: HANDLER!");
  1521. X    puts("Requires NULL: handler!");
  1522. X    xexit(1);
  1523. X    }
  1524. X    if (LogToStdout == 0) {
  1525. X    freopen("NULL:", "r", stdin);
  1526. X    freopen("NULL:", "w", stdout);
  1527. X    freopen("NULL:", "w", stderr);
  1528. X    }
  1529. X
  1530. X
  1531. X    /*
  1532. X     *    Timer Device
  1533. X     */
  1534. X
  1535. X    Iot.tr_node.io_Message.mn_ReplyPort = IoSink;
  1536. X    if (OpenDevice("timer.device", UNIT_VBLANK, &Iot, 0)) {
  1537. X    Iot.tr_node.io_Device = NULL;
  1538. X    xexit(20);
  1539. X    }
  1540. X    Iot.tr_node.io_Command = TR_ADDREQUEST;
  1541. X
  1542. X    /*
  1543. X     *    SERIAL.DEVICE
  1544. X     */
  1545. X
  1546. X    Iosr.IOSer.io_Message.mn_ReplyPort = IoSink;
  1547. X    Iosr.io_SerFlags = SERF_XDISABLED | SERF_7WIRE | SERF_RAD_BOOGIE | SERF_SHARED;
  1548. X    if (OpenDevice(DeviceName, DeviceUnit, &Iosr, 0)) {
  1549. X    Iosr.IOSer.io_Device = NULL;
  1550. X    xexit(21);
  1551. X    }
  1552. X
  1553. X    Iosw = Iosr;
  1554. X
  1555. X    Iosw.io_SerFlags = SERF_XDISABLED | SERF_RAD_BOOGIE | SERF_SHARED;
  1556. X    Iosw.io_ExtFlags = 0;
  1557. X    Iosw.io_Baud = Bauds[0];
  1558. X    Iosw.io_ReadLen = 8;
  1559. X    Iosw.io_WriteLen = 8;
  1560. X    Iosw.io_StopBits = 1;
  1561. X
  1562. X    SetParams(&Iosw);
  1563. X
  1564. X    /*
  1565. X     *    Run Operation
  1566. X     */
  1567. X
  1568. X    State = ST_WAITCD;
  1569. X    Iot.tr_time.tv_secs = 1;
  1570. X    Iot.tr_time.tv_micro= 0;
  1571. X    IotIP = 1;
  1572. X    SendIO(&Iot);
  1573. X
  1574. X    InitModem();
  1575. X
  1576. X    Signal(FindTask(NULL), IoSinkMask);
  1577. X
  1578. X    for (;;) {
  1579. X    long mask;
  1580. X    IOR  *ior;
  1581. X    GMsg *msg;
  1582. X    mask = Wait(SIGBREAKF_CTRL_C | IoSinkMask | ComPortMask);
  1583. X
  1584. X    ulog(2, "State = %d", State);
  1585. X
  1586. X    if (mask & SIGBREAKF_CTRL_C)
  1587. X        break;
  1588. X
  1589. X    if (msg = (GMsg *)GetMsg(ComPort)) {
  1590. X        do {
  1591. X        switch(msg->Cmd) {
  1592. X        case 'O':
  1593. X            DoOptions(msg->Data1, msg->Data2);
  1594. X            break;
  1595. X        }
  1596. X        ReplyMsg((MSG *)msg);
  1597. X        if (ZeroOption)
  1598. X            xexit(0);
  1599. X        } while (msg = (GMsg *)GetMsg(ComPort));
  1600. X        if (State == ST_WAITCD && !GotOffPort)
  1601. X        Disconnect(0);
  1602. X    }
  1603. X
  1604. X    while (ior = (IOR *)GetMsg(IoSink)) {
  1605. X        if (ior == (IOR *)&Iot) {
  1606. X        short diu;
  1607. X
  1608. X        IotIP = 0;
  1609. X        Iot.tr_time.tv_secs = 1;
  1610. X        Iot.tr_time.tv_micro= 0;
  1611. X
  1612. X        /*
  1613. X         *  If OpenCnt > 1, disable all processing.
  1614. X         *
  1615. X         *  When returns to <= 1 reset serial port.
  1616. X         */
  1617. X
  1618. X        diu = DeviceInUse();
  1619. X        if (diu) {
  1620. X            if (GotOffPort == 0) {
  1621. X            ulog(-1, "Device in use");
  1622. X            if (Locked)
  1623. X                ulog(-1, "getting off port");
  1624. X            SerialOff();
  1625. X            GotOffPort = 1;
  1626. X            State = ST_WAITCD;
  1627. X            }
  1628. X            SendIO(&Iot);
  1629. X            IotIP = 1;
  1630. X            continue;
  1631. X        }
  1632. X        if (GotOffPort) {
  1633. X            if (Locked == 0) {
  1634. X            LockSerialPort(DeviceName, DeviceUnit);
  1635. X            Locked = 1;
  1636. X            }
  1637. X            GotOffPort = 0;
  1638. X            ulog(-1, "Getty resetting");
  1639. X            SendIO(&Iot);
  1640. X            IotIP = 1;
  1641. X            Disconnect(1);
  1642. X            continue;
  1643. X        }
  1644. X        if (State == ST_WAITCD)
  1645. X            SerialOff();
  1646. X
  1647. X        if (State != ST_WAITCD && IosrIP == 0) {
  1648. X            if (Locked == 0)
  1649. X            LockSerialPort(DeviceName, DeviceUnit);
  1650. X            Locked = 1;
  1651. X            ulog(-1, "Serial Port Locked");
  1652. X
  1653. X            Iosr.IOSer.io_Command = CMD_READ;
  1654. X            Iosr.IOSer.io_Data = (APTR)RxBuf;
  1655. X            Iosr.IOSer.io_Length = 1;
  1656. X            SendIO(&Iosr);
  1657. X            IosrIP = 1;
  1658. X            ulog(1, "Carrier, Getty getting on port");
  1659. X        }
  1660. X
  1661. X        Iosw.IOSer.io_Command = SDCMD_QUERY;
  1662. X        DoIO(&Iosw);
  1663. X        if (IgnoreCD)
  1664. X            Iosw.io_Status &= ~CIAF_COMCD;
  1665. X
  1666. X        /*
  1667. X         *  If state connected and we loose carrier, disconnect.
  1668. X         *
  1669. X         *  If state connected and timeout occurs disconnect.
  1670. X         */
  1671. X
  1672. X        if (State != ST_WAITCD) {
  1673. X            if ((Iosw.io_Status & CIAF_COMCD) != 0) {
  1674. X            ulog(1, "Getty, Carrier lost");
  1675. X            Disconnect(0);
  1676. X            } else {
  1677. X            if (--CountDown == 0) {
  1678. X                ulog(1, "Getty, Timeout, Disconnecting");
  1679. X                Disconnect(1);
  1680. X                Iosw.io_Status |= CIAF_COMCD; /* for below */
  1681. X            }
  1682. X            }
  1683. X        }
  1684. X
  1685. X        switch(State) {
  1686. X        case ST_WAITCD:
  1687. X            if ((Iosw.io_Status & CIAF_COMCD) == 0) {
  1688. X            State = ST_CONNECT;
  1689. X            CountDown = 60;     /*    allow 60 seconds */
  1690. X            ulog(-1, "Carrier Detect");
  1691. X            } else {
  1692. X            Iot.tr_time.tv_secs = 2;
  1693. X            }
  1694. X            break;
  1695. X        case ST_CONNECT:
  1696. X            /*
  1697. X             *    Wait for CONNECT message, then send Login:
  1698. X             */
  1699. X
  1700. X            if (IgnoreConnect && HaveConnectMsg == 0) {
  1701. X            if (Wire7)
  1702. X                Set7Wire(&Iosw);
  1703. X            HaveConnectMsg = 1;
  1704. X            ulog(-1, "Connect");
  1705. X            }
  1706. X
  1707. X            if (HaveConnectMsg) {
  1708. X            FILE *fi;
  1709. X
  1710. X            Delay(50);
  1711. X            ClearRecv();
  1712. X            if (fi = fopen("Getty:Getty-Header", "r")) {
  1713. X                while (fgets(ScrBuf, sizeof(ScrBuf), fi)) {
  1714. X                SerPuts(ScrBuf);
  1715. X                SerPuts("\r");
  1716. X                }
  1717. X                fclose(fi);
  1718. X            }
  1719. X            SerPuts("Login: ");
  1720. X            ulog(-1, "Getty, Connect, Login");
  1721. X            State = ST_LOGIN;
  1722. X            Index = 0;
  1723. X            HaveLogin = 0;
  1724. X            LoginBuf[0] = 0;
  1725. X            }
  1726. X            break;
  1727. X        case ST_LOGIN:        /*    wait Login: response    */
  1728. X            if (HaveLogin) {
  1729. X            if (LoginBuf[0] == 0) {
  1730. X                State = ST_CONNECT;
  1731. X                break;
  1732. X            }
  1733. X            ClearRecv();
  1734. X            PasswdBuf[0] = 0;
  1735. X
  1736. X            /*
  1737. X             *  If no password required, else request
  1738. X             *  password.
  1739. X             */
  1740. X
  1741. X            if (CheckLoginAndPassword()) {
  1742. X                HavePasswd = 1;
  1743. X                Index = 0;
  1744. X                State = ST_PASSWD;
  1745. X            } else {
  1746. X                SerPuts("Password: ");
  1747. X                ulog(1, "Getty, Passwd");
  1748. X                State = ST_PASSWD;
  1749. X                HavePasswd = 0;
  1750. X                Index = 0;
  1751. X            }
  1752. X            }
  1753. X            break;
  1754. X        case ST_PASSWD:     /*    wait Password: response */
  1755. X            if (HavePasswd) {
  1756. X            if (CheckLoginAndPassword()) {
  1757. X                ulog(-1, "login %s", LoginBuf);
  1758. X
  1759. X                /*
  1760. X                 *    Disable read requests but leave serial
  1761. X                 *    port locked.
  1762. X                 */
  1763. X
  1764. X                if (IosrIP) {
  1765. X                AbortIO(&Iosr);
  1766. X                WaitIO(&Iosr);
  1767. X                IosrIP = 0;
  1768. X                }
  1769. X
  1770. X                /*
  1771. X                 *    If run successful, leave read req and
  1772. X                 *    timer disabled.
  1773. X                 */
  1774. X
  1775. X                RunPasswdEntry();
  1776. X
  1777. X                if (DropOnExit)
  1778. X                Disconnect(1);
  1779. X                else
  1780. X                State = ST_CONNECT;
  1781. X                ulog(-1, "disconnect");
  1782. X            } else {
  1783. X                SerPuts("Login Failed.\r\n\n");
  1784. X                State = ST_CONNECT;
  1785. X                ulog(-1, "LoginFailed user=%s pass=%s", LoginBuf, PasswdBuf);
  1786. X            }
  1787. X            HaveLogin = 0;
  1788. X            HavePasswd= 0;
  1789. X            LoginBuf[0] = 0;
  1790. X            }
  1791. X            break;
  1792. X        }
  1793. X
  1794. X        /*
  1795. X         *  Make no read requests while running 3rd party
  1796. X         *  program, else resend read request.
  1797. X         */
  1798. X
  1799. X        if (IotIP == 0) {
  1800. X            IotIP = 1;
  1801. X            SendIO(&Iot);
  1802. X        }
  1803. X        }
  1804. X
  1805. X        /*
  1806. X         *    RECEIVED SERIAL READ DATA
  1807. X         */
  1808. X
  1809. X        if (ior == (IOR *)&Iosr) {
  1810. X        IosrIP = 0;
  1811. X
  1812. X        Iosw.IOSer.io_Command = SDCMD_QUERY;
  1813. X        DoIO(&Iosw);
  1814. X        if (IgnoreCD)
  1815. X            Iosw.io_Status &= ~CIAF_COMCD;
  1816. X
  1817. X        /*
  1818. X         *  BREAK used to switch baud rates between allowed
  1819. X         *  values
  1820. X         */
  1821. X
  1822. X        if (Iosw.io_Status & IO_STATF_READBREAK) {
  1823. X            if (BaudAdjust == 0 && (State == ST_LOGIN || State == ST_PASSWD)) {
  1824. X            if (++BIndex == arysize(Bauds))
  1825. X                BIndex = 0;
  1826. X            if (Bauds[BIndex] == 0)
  1827. X                BIndex = 0;
  1828. X            Iosw.io_Baud = Bauds[BIndex];
  1829. X            SetParams(&Iosw);
  1830. X            if (Wire7)
  1831. X                Set7Wire(&Iosw);
  1832. X            ulog(1, "<BREAK> to %d baud", Iosw.io_Baud);
  1833. X            Delay(100);
  1834. X            ClearRecv();
  1835. X            Index = 0;
  1836. X            State = ST_CONNECT;
  1837. X            }
  1838. X        } else
  1839. X        if (Iosr.IOSer.io_Actual == 1) {
  1840. X            char *ptr;
  1841. X            UBYTE c = (UBYTE)RxBuf[0];
  1842. X
  1843. X            ulog(2, "Rx %02x %c", c, (c < 32) ? ' ' : c);
  1844. X            c &= 0x7F;
  1845. X
  1846. X            switch(State) {
  1847. X            case ST_WAITCD:    /*  looking for CONNECT msg */
  1848. X            case ST_CONNECT:    /*  looking for CONNECT msg */
  1849. X            ptr = ConnectBuf;
  1850. X            break;
  1851. X            case ST_LOGIN:    /*  looking for login name  */
  1852. X            ptr = LoginBuf;
  1853. X            break;
  1854. X            case ST_PASSWD:    /*  looking for password    */
  1855. X            ptr = PasswdBuf;
  1856. X            break;
  1857. X            }
  1858. X            if (State == ST_LOGIN && HaveLogin)
  1859. X            c = 0;
  1860. X            if (State == ST_PASSWD && HavePasswd)
  1861. X            c = 0;
  1862. X
  1863. X            switch(c) {
  1864. X            case 0:
  1865. X            break;
  1866. X            case 8:
  1867. X            if (State == ST_LOGIN && HaveLogin)
  1868. X                break;
  1869. X            if (Index) {
  1870. X                if (State == ST_LOGIN)
  1871. X                SerPuts("\010 \010");
  1872. X                --Index;
  1873. X            }
  1874. X            break;
  1875. X            case 10:
  1876. X            case 13:
  1877. X            ptr[Index] = 0;
  1878. X            Index = 0;
  1879. X            switch(State) {
  1880. X            case ST_WAITCD:
  1881. X            case ST_CONNECT:
  1882. X                if (strncmp(ptr, "CONNECT", 7)) {
  1883. X                ulog(1, "Looking for CONNECT, got '%s'", ptr);
  1884. X                break;
  1885. X                }
  1886. X                Delay(50);
  1887. X                HaveConnectMsg = 1;
  1888. X                if (BaudAdjust) {
  1889. X                ulog(-1, "Connect Auto-Baud %d", Iosw.io_Baud);
  1890. X                } else {
  1891. X                char *str = ptr + 7;
  1892. X                while (*str && (*str == 9 || *str == ' '))
  1893. X                    ++str;
  1894. X                if (*str >= '0' && *str <= '9')
  1895. X                    Iosw.io_Baud = atoi(str);
  1896. X                else
  1897. X                    Iosw.io_Baud = Bauds[0];
  1898. X                SetParams(&Iosw);
  1899. X                ulog(-1, "Connect at %d baud", Iosw.io_Baud);
  1900. X                }
  1901. X                if (Wire7)
  1902. X                Set7Wire(&Iosw);
  1903. X                break;
  1904. X            case ST_LOGIN:
  1905. X                HaveLogin = 1;
  1906. X                SerPuts("\r\n");
  1907. X                ulog(1, "Login: %s", ptr);
  1908. X                break;
  1909. X            case ST_PASSWD:
  1910. X                HavePasswd = 1;
  1911. X                SerPuts("\r\n");
  1912. X                ulog(1, "Password: %s", ptr);
  1913. X                break;
  1914. X            }
  1915. X            break;
  1916. X            default:
  1917. X            if (Index == 31)
  1918. X                break;
  1919. X            if (State == ST_LOGIN) {
  1920. X                char cc[2];
  1921. X                cc[0] = c;
  1922. X                cc[1] = 0;
  1923. X                SerPuts(cc);
  1924. X            }
  1925. X            ptr[Index++] = c;
  1926. X            break;
  1927. X            }
  1928. X        }
  1929. X        if (IosrIP == 0) {
  1930. X            Iosr.IOSer.io_Command = CMD_READ;
  1931. X            Iosr.IOSer.io_Data = (APTR)RxBuf;
  1932. X            Iosr.IOSer.io_Length = 1;
  1933. X            SendIO(&Iosr);
  1934. X            IosrIP = 1;
  1935. X        }
  1936. X        }
  1937. X    }
  1938. X    }
  1939. X    xexit(0);
  1940. X}
  1941. X
  1942. Xvoid
  1943. XSerialOff()
  1944. X{
  1945. X    if (IosrIP) {
  1946. X    AbortIO(&Iosr);
  1947. X    WaitIO(&Iosr);
  1948. X    IosrIP = 0;
  1949. X    }
  1950. X    if (Locked) {
  1951. X    UnLockSerialPort(DeviceName, DeviceUnit);
  1952. X    Locked = 0;
  1953. X    ulog(1, "Serial Port UnLocked");
  1954. X    }
  1955. X}
  1956. X
  1957. Xvoid
  1958. Xxexit(code)
  1959. X{
  1960. X    if (ComPortMask) {
  1961. X    GMsg *msg;
  1962. X    Forbid();
  1963. X    while (msg = (GMsg *)GetMsg(ComPort))
  1964. X        ReplyMsg((MSG *)msg);
  1965. X    DeletePort(ComPort);
  1966. X    Permit();
  1967. X    }
  1968. X    if (IotIP) {
  1969. X    AbortIO(&Iot);
  1970. X    WaitIO(&Iot);
  1971. X    }
  1972. X    if (Iot.tr_node.io_Device)
  1973. X    CloseDevice(&Iot);
  1974. X
  1975. X    if (IosrIP) {
  1976. X    AbortIO(&Iosr);
  1977. X    WaitIO(&Iosr);
  1978. X    }
  1979. X    if (Iosr.IOSer.io_Device)
  1980. X    CloseDevice(&Iosr);
  1981. X
  1982. X    if (IoSink)
  1983. X    DeletePort(IoSink);
  1984. X
  1985. X    if (NullFH)
  1986. X    Close(NullFH);
  1987. X
  1988. X    if (Locked)
  1989. X    UnLockSerialPort(DeviceName, DeviceUnit);
  1990. X
  1991. X    exit(code);
  1992. X}
  1993. X
  1994. Xvoid
  1995. XSerPuts(str)
  1996. Xchar *str;
  1997. X{
  1998. X    Iosw.IOSer.io_Command = CMD_WRITE;
  1999. X    Iosw.IOSer.io_Data = (APTR)str;
  2000. X    Iosw.IOSer.io_Length = strlen(str);
  2001. X    DoIO(&Iosw);
  2002. X}
  2003. X
  2004. Xstatic short RxDisableIP;
  2005. X
  2006. Xvoid
  2007. XRxDisable()
  2008. X{
  2009. X    RxDisableIP = IosrIP;
  2010. X    if (IosrIP) {
  2011. X    AbortIO(&Iosr);
  2012. X    WaitIO(&Iosr);
  2013. X    IosrIP = 0;
  2014. X    }
  2015. X}
  2016. X
  2017. Xvoid
  2018. XRxEnable()
  2019. X{
  2020. X    if (RxDisableIP && IosrIP == 0) {
  2021. X    Iosr.IOSer.io_Command = CMD_READ;
  2022. X    Iosr.IOSer.io_Data = (APTR)RxBuf;
  2023. X    Iosr.IOSer.io_Length = 1;
  2024. X    SendIO(&Iosr);
  2025. X    IosrIP = 1;
  2026. X    }
  2027. X}
  2028. X
  2029. Xvoid
  2030. XClearRecv()
  2031. X{
  2032. X    RxDisable();
  2033. X    ulog(1, "Clear beg");
  2034. X    for (;;) {
  2035. X    Iosr.IOSer.io_Command = SDCMD_QUERY;
  2036. X    DoIO(&Iosr);
  2037. X    if ((Iosr.IOSer.io_Length = Iosr.IOSer.io_Actual) <= 0)
  2038. X        break;
  2039. X    if (Iosr.IOSer.io_Length > sizeof(RxBuf))
  2040. X        Iosr.IOSer.io_Length = sizeof(RxBuf);
  2041. X    Iosr.IOSer.io_Data = (APTR)RxBuf;
  2042. X    Iosr.IOSer.io_Command = CMD_READ;
  2043. X    DoIO(&Iosr);
  2044. X    }
  2045. X    ulog(1, "Clear end");
  2046. X    RxEnable();
  2047. X}
  2048. X
  2049. Xvoid
  2050. XSetParams(ior)
  2051. XIOSER *ior;
  2052. X{
  2053. X    int error;
  2054. X
  2055. X    if (IosrIP)
  2056. X    AbortIO(&Iosr);
  2057. X    ior->IOSer.io_Command = SDCMD_SETPARAMS;
  2058. X    error = DoIO(ior);
  2059. X    if (error)
  2060. X    printf("SetParams, error %d\n", error);
  2061. X}
  2062. X
  2063. Xvoid
  2064. XSet7Wire(ior)
  2065. XIOSER *ior;
  2066. X{
  2067. X    short error;
  2068. X
  2069. X    if (IosrIP)
  2070. X    AbortIO(&Iosr);
  2071. X    ior->IOSer.io_Command = SDCMD_SETPARAMS;
  2072. X    ior->io_SerFlags |= SERF_7WIRE;
  2073. X    error = DoIO(ior);
  2074. X    ior->io_SerFlags &= ~SERF_7WIRE;
  2075. X    if (error)
  2076. X    printf("SetParams, error %d\n", error);
  2077. X}
  2078. X
  2079. Xvoid
  2080. XDisconnect(dropdtr)
  2081. X{
  2082. X    short retry = (IgnoreDTR) ? 2 : 10;
  2083. X
  2084. X    ulog(1, "Disconnect drop=%d", dropdtr);
  2085. X    HaveConnectMsg = 0;
  2086. X    HaveLogin    = 0;
  2087. X    HavePasswd    = 0;
  2088. X    LoginBuf[0] = 0;
  2089. X    PasswdBuf[0] = 0;
  2090. X    Index = 0;
  2091. X    State = ST_WAITCD;
  2092. X
  2093. X    while (dropdtr && DeviceInUse() == 0) {
  2094. X    short i;
  2095. X
  2096. X    RxDisable();
  2097. X
  2098. X    if (IgnoreDTR) {
  2099. X        if (ModemType != 'd') {
  2100. X        Delay(70);
  2101. X        SerPuts("+++");
  2102. X        Delay(70);
  2103. X        SerPuts("\010\010\r");
  2104. X        Delay(10);
  2105. X        SerPuts("ATH0\r");
  2106. X        Delay(120);
  2107. X        }
  2108. X    } else {
  2109. X        CloseDevice(&Iosr);
  2110. X        Iosr.IOSer.io_Device = NULL;    /*    so xexit doesn't reclose */
  2111. X        for (i = 0; i < 5; ++i) {       /*  5 seconds   */
  2112. X        Delay(50);
  2113. X        if (SetSignal(SIGBREAKF_CTRL_C, 0) & SIGBREAKF_CTRL_C)
  2114. X            xexit(23);
  2115. X        }
  2116. X
  2117. X       /*
  2118. X        *  Use Iosr to re-open serial device so we don't loose
  2119. X        *  our config.
  2120. X        */
  2121. X
  2122. X        if (OpenDevice(DeviceName, DeviceUnit, &Iosr, 0)) {
  2123. X        Iosr.IOSer.io_Device = NULL;
  2124. X        xexit(22);
  2125. X        }
  2126. X        Iosw.IOSer.io_Device = Iosr.IOSer.io_Device;
  2127. X        Iosw.IOSer.io_Unit = Iosr.IOSer.io_Unit;
  2128. X        SetParams(&Iosw);
  2129. X    }
  2130. X
  2131. X    /*
  2132. X     *  Loop until carrier lost
  2133. X     */
  2134. X
  2135. X    Iosw.IOSer.io_Command = SDCMD_QUERY;
  2136. X    DoIO(&Iosw);
  2137. X    if (IgnoreCD)
  2138. X        Iosw.io_Status &= ~CIAF_COMCD;
  2139. X
  2140. X    RxEnable();
  2141. X
  2142. X    if ((Iosw.io_Status & CIAF_COMCD) != 0)
  2143. X        break;
  2144. X    if (--retry == 0) {
  2145. X        if (IgnoreDTR == 0)
  2146. X        puts("Getty: unable to disconnect!");
  2147. X        break;
  2148. X    }
  2149. X    }
  2150. X    if (DeviceInUse() == 0)
  2151. X    InitModem();
  2152. X}
  2153. X
  2154. Xvoid
  2155. XInitModem()
  2156. X{
  2157. X    char buf[64];
  2158. X    short i;
  2159. X
  2160. X    RxDisable();
  2161. X    ulog(1, "Init Modem");
  2162. X    Iosw.io_Baud = Bauds[0];    /*  reset baud rate */
  2163. X    BIndex = 0;
  2164. X    SetParams(&Iosw);
  2165. X    RxEnable();
  2166. X
  2167. X    switch(ModemType) {
  2168. X    case 'm':               /*  Multi Modem     */
  2169. X    SerPuts("\010\010\r");
  2170. X    Delay(10);
  2171. X    SerPuts("AT\r");
  2172. X    Delay(50);
  2173. X    sprintf(buf, "ATM%dS0=%dX4$BA%d&E%d\r",
  2174. X        SpeakerLevel,
  2175. X        AnswerRing,
  2176. X        !BaudAdjust,
  2177. X        (Wire7) ? 4 : 3
  2178. X    );
  2179. X    SerPuts(buf);
  2180. X    break;
  2181. X    case 'h':
  2182. X    SerPuts("\010\010\r");
  2183. X    Delay(10);
  2184. X    SerPuts("ATZ\r");
  2185. X    Delay(120);
  2186. X    strcpy(buf, "AT");
  2187. X    if (SpeakerOpt)
  2188. X        sprintf(buf + strlen(buf), "M%d", SpeakerLevel);
  2189. X    sprintf(buf + strlen(buf), "S0=%d", AnswerRing);
  2190. X    strcat(buf, "\r");
  2191. X    SerPuts(buf);
  2192. X    break;
  2193. X    case 'd':
  2194. X    SerPuts("\010\010\r");
  2195. X    break;
  2196. X    }
  2197. X    for (i = 0; i < arysize(AtFields) && AtFields[i]; ++i) {
  2198. X    Delay(50);
  2199. X    SerPuts(AtFields[i]);
  2200. X    SerPuts("\r");
  2201. X    }
  2202. X    Delay(20);
  2203. X    ClearRecv();
  2204. X    Index = 0;
  2205. X}
  2206. X
  2207. Xvoid
  2208. XDoOptions(ac, av)
  2209. Xchar *av[];
  2210. X{
  2211. X    short i;
  2212. X    short bi = 0;
  2213. X    short fi = 0;
  2214. X    long v;
  2215. X
  2216. X    for (i = 1; i < ac; ++i) {
  2217. X    char *ptr = av[i];
  2218. X    if (*ptr != '-') {
  2219. X        if (fi != arysize(AtFields))
  2220. X        AtFields[fi++] = ptr;
  2221. X        else
  2222. X        puts("AT field overflow");
  2223. X        continue;
  2224. X    }
  2225. X    if (*++ptr)             /*  skip -      */
  2226. X        ++ptr;        /*  and option    */
  2227. X    v = atoi(ptr);
  2228. X    switch(ptr[-1]) {
  2229. X    case '0':
  2230. X        ZeroOption = 1;
  2231. X        break;
  2232. X    case '7':
  2233. X        Wire7 = 1;
  2234. X        break;
  2235. X    case 'S':
  2236. X        DeviceName = ptr;
  2237. X        break;
  2238. X    case 'U':
  2239. X        DeviceUnit = v;
  2240. X        break;
  2241. X    case 'M':
  2242. X        ModemType = *ptr;
  2243. X        break;
  2244. X    case 'A':
  2245. X        BaudAdjust = 1;
  2246. X        break;
  2247. X    case 'B':
  2248. X        if (bi != arysize(Bauds))
  2249. X        Bauds[bi++] = v;
  2250. X        else
  2251. X        puts("-B field overflow");
  2252. X        break;
  2253. X    case 'm':
  2254. X        SpeakerOpt = 1;
  2255. X        SpeakerLevel = v;
  2256. X        break;
  2257. X    case 'r':
  2258. X        AnswerRing = v;
  2259. X        break;
  2260. X    case 'h':
  2261. X        IgnoreCD = !v;
  2262. X        break;
  2263. X    case 'c':
  2264. X        IgnoreConnect = !v;
  2265. X        break;
  2266. X    case 'd':
  2267. X        IgnoreDTR = !v;
  2268. X        break;
  2269. X    case 'x':
  2270. X        LogLevel = v;
  2271. X        LogToStdout = (v >= 0);
  2272. X        break;
  2273. X    default:
  2274. X        printf("Warning, Bad option: -%s\n", ptr);
  2275. X        break;
  2276. X    }
  2277. X    }
  2278. X    if (fi && fi != arysize(AtFields))
  2279. X    AtFields[fi] = NULL;
  2280. X    if (bi && bi != arysize(Bauds))
  2281. X    Bauds[bi] = 0;
  2282. X}
  2283. X
  2284. XDeviceInUse()
  2285. X{
  2286. X    return(Iosr.IOSer.io_Device->dd_Library.lib_OpenCnt > 1);
  2287. X}
  2288. X
  2289. END_OF_FILE
  2290. if test 19742 -ne `wc -c <'src/getty/getty.c'`; then
  2291.     echo shar: \"'src/getty/getty.c'\" unpacked with wrong size!
  2292. fi
  2293. # end of 'src/getty/getty.c'
  2294. fi
  2295. echo shar: End of archive 9 \(of 16\).
  2296. cp /dev/null ark9isdone
  2297. MISSING=""
  2298. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  2299.     if test ! -f ark${I}isdone ; then
  2300.     MISSING="${MISSING} ${I}"
  2301.     fi
  2302. done
  2303. if test "${MISSING}" = "" ; then
  2304.     echo You have unpacked all 16 archives.
  2305.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2306. else
  2307.     echo You still need to unpack the following archives:
  2308.     echo "        " ${MISSING}
  2309. fi
  2310. ##  End of shell archive.
  2311. exit 0
  2312. -- 
  2313. Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
  2314.     amiga@cs.odu.edu    
  2315. or    amiga@xanth.cs.odu.edu    ( obsolescent mailers may need this address )
  2316. or    ...!uunet!xanth!amiga    ( very obsolescent mailers need this address )
  2317.  
  2318. Comments, questions, and suggestions should be addressed to ``amiga-request''
  2319. (please only use ``amiga'' for actual submissions) at the above addresses.
  2320.